import { BuildTaskType } from "../src/model/BuildTask";
import path from "node:path";
import { buildTypeList } from "./buildTypeList";
export type TaskCmd = {
  type: BuildTaskType;
  cwd: string;
  cmd: string;
};

// 支持的任务类型
export const supportTaskType: BuildTaskType[] = buildTypeList.map(
  (v) => v.type
);

const buildCmd = `pnpm build`;
const cwdPrefix = path.resolve(path.resolve(), "../projects");

const cwdPath = (dirName: string) => {
  return path.resolve(cwdPrefix, dirName);
};

const cmdObj: Partial<Record<BuildTaskType, TaskCmd>> = {};
buildTypeList.map((v) => {
  Object.assign(cmdObj, {
    [v.type]: {
      type: v.type,
      cwd: cwdPath(v.type),
      cmd: buildCmd,
    } as TaskCmd,
  });
});

// 命令行
export { cmdObj };
